package com.appleyk.controller;


import com.appleyk.node.User;
import com.appleyk.relation.LikeRelation;
import com.appleyk.repository.LikeRelationRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/d/a")
public class LikeRelationController {

    @Autowired
    private LikeRelationRepository likeRepository;

    @GetMapping("/c")
    public List<LikeRelation> findLikes(){
        System.out.println("進入了方法");
        List<LikeRelation> likes = likeRepository.getLikes();
        for (LikeRelation likeRelation : likes) {
            User sNode = (User) likeRelation.getStartNode();
            User eNode = (User) likeRelation.getEndNode();
            System.out.println(sNode.getName() + "--喜欢-->" + eNode.getName()
                    +" == reason: "+likeRelation.getReason());
        }
        return likes;
    }


}
